package com.finance.system.service;

import com.finance.framework.lang.Page;
import com.finance.framework.lang.PageResultBO;
import com.finance.system.bean.pojo.Warehouse;
import com.finance.system.dao.WarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: gyw
 * @Date: Created in 2017-09-20
 */
@Service
public class WarehouseService implements IWarehouseService {

    @Autowired
    private WarehouseMapper warehouseMapper;

    @Override
    public List<Warehouse> listAll() {
        return warehouseMapper.listAll();
    }

    @Override
    public String getCodeByName(String warehouseName) {
        return warehouseMapper.getCodeByName(warehouseName);
    }

    @Override
    public List<Warehouse> list() {
        return warehouseMapper.list();
    }

    @Override
    public PageResultBO<Warehouse> listByPage(Page page) {
        PageResultBO<Warehouse> resultBO = new PageResultBO<Warehouse>();
        List<Warehouse> list = this.warehouseMapper.listByPage(page);
        resultBO.setDataList(list);
        resultBO.setPageSize(page.getPageSize());
        resultBO.setPageNo(page.getPageNo());
        resultBO.setTotalRecord(page.getTotalRecord());
        return resultBO;
    }
}
